home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / ip / nfs / nfswatch4.0 / RCS / nfslogsum.c,v < prev    next >
Encoding:
Text File  |  1993-03-01  |  17.6 KB  |  1,003 lines

  1. head    4.0;
  2. access;
  3. symbols;
  4. locks; strict;
  5. comment    @ * @;
  6.  
  7.  
  8. 4.0
  9. date    93.03.01.19.59.00;    author davy;    state Exp;
  10. branches;
  11. next    3.4;
  12.  
  13. 3.4
  14. date    93.01.16.19.08.59;    author davy;    state Exp;
  15. branches;
  16. next    3.3;
  17.  
  18. 3.3
  19. date    93.01.15.19.33.39;    author davy;    state Exp;
  20. branches;
  21. next    3.2;
  22.  
  23. 3.2
  24. date    93.01.14.03.41.21;    author davy;    state Exp;
  25. branches;
  26. next    3.1;
  27.  
  28. 3.1
  29. date    93.01.13.20.18.17;    author davy;    state Exp;
  30. branches;
  31. next    3.0;
  32.  
  33. 3.0
  34. date    91.01.23.08.23.08;    author davy;    state Exp;
  35. branches;
  36. next    1.2;
  37.  
  38. 1.2
  39. date    90.08.17.15.47.27;    author davy;    state Exp;
  40. branches;
  41. next    1.1;
  42.  
  43. 1.1
  44. date    88.11.29.11.20.38;    author davy;    state Released;
  45. branches;
  46. next    ;
  47.  
  48.  
  49. desc
  50. @NFSWATCH - monitor Network File System traffic on the network.
  51. @
  52.  
  53.  
  54. 4.0
  55. log
  56. @NFSWATCH Version 4.0.
  57. @
  58. text
  59. @#ifndef lint
  60. static char *RCSid = "$Header: /home/harbor/davy/system/nfswatch/RCS/nfslogsum.c,v 3.4 1993/01/16 19:08:59 davy Exp davy $";
  61. #endif
  62.  
  63. #include "os.h"
  64.  
  65. /*
  66.  * nfslogsum - summarize nfswatch log file
  67.  *
  68.  * David A. Curry                Jeffrey C. Mogul
  69.  * Purdue University                Digital Equipment Corporation
  70.  * Engineering Computer Network            Western Research Laboratory
  71.  * 1285 Electrical Engineering Building        250 University Avenue
  72.  * West Lafayette, IN 47907-1285        Palo Alto, CA 94301
  73.  * davy@@ecn.purdue.edu                mogul@@decwrl.dec.com
  74.  *
  75.  * $Log: nfslogsum.c,v $
  76.  * Revision 3.4  1993/01/16  19:08:59  davy
  77.  * Corrected Jeff's address.
  78.  *
  79.  * Revision 3.3  1993/01/15  19:33:39  davy
  80.  * Miscellaneous cleanups.
  81.  *
  82.  * Revision 3.2  1993/01/14  03:41:21  davy
  83.  * Changed "Yellow Pages/NIS" to "YP/NIS/NIS+".
  84.  *
  85.  * Revision 3.1  1993/01/13  20:18:17  davy
  86.  * Put in OS-specific define scheme, and merged in Tim Hudson's code for
  87.  * SGI systems (as yet untested).
  88.  *
  89.  * Revision 3.0  1991/01/23  08:23:08  davy
  90.  * NFSWATCH Version 3.0.
  91.  *
  92.  * Revision 1.2  90/08/17  15:47:27  davy
  93.  * NFSWATCH Version 2.0.
  94.  * 
  95.  * Revision 1.1  88/11/29  11:20:38  davy
  96.  * NFSWATCH Release 1.0
  97.  * 
  98.  */
  99. #include <sys/param.h>
  100. #include <stdio.h>
  101.  
  102. #include "nfswatch.h"
  103.  
  104. char        *pname;                /* program name        */
  105. char        *logfile = LOGFILE;        /* log file name    */
  106.  
  107. int        logentries;            /* # of entries        */
  108. int        verbose = 0;            /* print more info    */
  109. int        maxlogentries = -1;        /* stop at this many    */
  110.  
  111. Counter        total_pkts;            /* total pkts this time    */
  112. Counter        tohost_pkts;            /* total pkts to host    */
  113. Counter        dropped_pkts;            /* total dropped pkts    */
  114.  
  115. char        *startdate;            /* time started        */
  116. char        *enddate;            /* time finished    */
  117.  
  118. char        srchost[MAXHOSTNAMELEN];    /* source host name    */
  119. char        dsthost[MAXHOSTNAMELEN];    /* destination host name*/
  120.  
  121. NFSCounter    nfs_counters[MAXEXPORT];    /* NFS pkt counters    */
  122. FileCounter    fil_counters[MAXEXPORT];    /* file pkt counters    */
  123. PacketCounter    pkt_counters[PKT_NCOUNTERS];    /* type pkt counters    */
  124.  
  125. char    *nfs_procs[] = {
  126.     "NULLPROC",    " GETATTR",    " SETATTR",    " GETROOT",
  127.     "  LOOKUP",    "READLINK",    "    READ",    "  WCACHE",
  128.     "   WRITE",    "  CREATE",    "  REMOVE",    "  RENAME",
  129.     "    LINK",    " SYMLINK",    "   MKDIR",    "   RMDIR",
  130.     " READDIR",    "  STATFS",    0
  131. };
  132.  
  133. char        *index();
  134. char        *savestr();
  135.  
  136. void        dumpit();
  137. void        dumpit2();
  138. void        parsenfs();
  139. void        parsetop();
  140. void        parsefile();
  141. void        parsepkts();
  142. void        parseproc();
  143. void        clearvars();
  144. void        parsetotals();
  145.  
  146. main(argc, argv)
  147. int argc;
  148. char **argv;
  149. {
  150.     FILE *logfp;
  151.     int printed = 0;
  152.     char line[BUFSIZ];
  153.  
  154.     pname = *argv;
  155.  
  156.     /*
  157.      * Process arguments.
  158.      */
  159.     while (--argc) {
  160.         if (**++argv != '-') {
  161.             logfile = *argv;
  162.             continue;
  163.         }
  164.  
  165.         switch (*++*argv) {
  166.         case 'v':
  167.             verbose++;
  168.             break;
  169.         default:
  170.             maxlogentries = atoi(*argv);
  171.             break;
  172.         }
  173.     }
  174.  
  175.     /*
  176.      * Open the log file.
  177.      */
  178.     if ((logfp = fopen(logfile, "r")) == NULL) {
  179.         (void) fprintf(stderr, "%s: cannot open \"%s\"\n", pname, logfile);
  180.         (void) exit(1);
  181.     }
  182.  
  183.     /*
  184.      * Read lines...
  185.      */
  186.     while (fgets(line, sizeof(line), logfp) != NULL) {
  187.         /*
  188.          * Skip blank comments.
  189.          */
  190.         if (!strcmp(line, "#\n"))
  191.             continue;
  192.  
  193.         /*
  194.          * Start of a new log session.
  195.          */
  196.         if (!strcmp(line, "# startlog\n")) {
  197.             clearvars();
  198.             printed = 0;
  199.             continue;
  200.         }
  201.  
  202.         /*
  203.          * Start of a new log entry.
  204.          */
  205.         if (!strcmp(line, "# begin\n")) {
  206.             parsetop(logfp);
  207.             continue;
  208.         }
  209.  
  210.         /*
  211.          * End of a log entry.
  212.          */
  213.         if (!strcmp(line, "# end\n")) {
  214.             logentries++;
  215.  
  216.             /*
  217.              * If we've read the max, we're done.
  218.              */
  219.             if ((maxlogentries > 0) &&
  220.                 (logentries >= maxlogentries)) {
  221.                 dumpit();
  222.                 exit(0);
  223.             }
  224.  
  225.             continue;
  226.         }
  227.  
  228.         /*
  229.          * End of log session.
  230.          */
  231.         if (!strcmp(line, "# endlog\n")) {
  232.             printed++;
  233.             dumpit();
  234.             continue;
  235.         }
  236.  
  237.         /*
  238.          * Start of NFS counter section.
  239.          */
  240.         if (!strncmp(line, "# nfs counters ", 15)) {
  241.             parsenfs(logfp);
  242.             continue;
  243.         }
  244.  
  245.         /*
  246.          * Start of file counter section.
  247.          */
  248.         if (!strncmp(line, "# file counters ", 16)) {
  249.             parsefile(logfp);
  250.             continue;
  251.         }
  252.  
  253.         /*
  254.          * Start of total packet section.
  255.          */
  256.         if (!strncmp(line, "# total packets ", 16)) {
  257.             parsetotals(logfp);
  258.             continue;
  259.         }
  260.  
  261.         /*
  262.          * Start of packet counter section.
  263.          */
  264.         if (!strncmp(line, "# packet counters ", 18)) {
  265.             parsepkts(logfp);
  266.             continue;
  267.         }
  268.  
  269.         /*
  270.          * Source host.
  271.          */
  272.         if (!strncmp(line, "#    Packets from: ", 19)) {
  273.             (void) strcpy(srchost, line + 19);
  274.             continue;
  275.         }
  276.  
  277.         /*
  278.          * Destination host.
  279.          */
  280.         if (!strncmp(line, "#    Packets to:   ", 19)) {
  281.             (void) strcpy(dsthost, line + 19);
  282.             continue;
  283.         }
  284.     }
  285.  
  286.     /*
  287.      * In case there's no endlog (logfile in progress).
  288.      */
  289.     if (!printed)
  290.         dumpit();
  291.  
  292.     (void) fclose(logfp);
  293.     (void) exit(0);
  294. }
  295.  
  296. /*
  297.  * clearvars - clear variables between log sessions.
  298.  */
  299. void
  300. clearvars()
  301. {
  302.     register int i;
  303.  
  304.     logentries = 0;
  305.     total_pkts = 0;
  306.     tohost_pkts = 0;
  307.     dropped_pkts = 0;
  308.  
  309.     if (startdate != NULL) {
  310.         (void) free(startdate);
  311.         startdate = NULL;
  312.     }
  313.  
  314.     if (enddate != NULL) {
  315.         (void) free(enddate);
  316.         enddate = NULL;
  317.     }
  318.  
  319.     (void) bzero((char *) pkt_counters,
  320.         PKT_NCOUNTERS * sizeof(PacketCounter));
  321.  
  322.     /*
  323.      * Set up the strings.
  324.      */
  325.     pkt_counters[PKT_NDREAD].pc_name = "ND Read";
  326.     pkt_counters[PKT_NDWRITE].pc_name = "ND Write";
  327.     pkt_counters[PKT_NFSREAD].pc_name = "NFS Read";
  328.     pkt_counters[PKT_NFSWRITE].pc_name = "NFS Write";
  329.     pkt_counters[PKT_NFSMOUNT].pc_name = "NFS Mount";
  330.     pkt_counters[PKT_YELLOWPAGES].pc_name = "YP/NIS/NIS+";
  331.     pkt_counters[PKT_RPCAUTH].pc_name = "RPC Authorization";
  332.     pkt_counters[PKT_OTHERRPC].pc_name = "Other RPC Packets";
  333.     pkt_counters[PKT_TCP].pc_name = "TCP Packets";
  334.     pkt_counters[PKT_UDP].pc_name = "UDP Packets";
  335.     pkt_counters[PKT_ICMP].pc_name = "ICMP Packets";
  336.     pkt_counters[PKT_ROUTING].pc_name = "Routing Control";
  337.     pkt_counters[PKT_ARP].pc_name = "Address Resolution";
  338.     pkt_counters[PKT_RARP].pc_name = "Reverse Addr Resol";
  339.     pkt_counters[PKT_BROADCAST].pc_name = "Ethernet Broadcast";
  340.     pkt_counters[PKT_OTHER].pc_name = "Other Packets";
  341.  
  342.     for (i = 0; i < MAXEXPORT; i++) {
  343.         if (nfs_counters[i].nc_name != NULL) {
  344.             (void) free(nfs_counters[i].nc_name);
  345.             nfs_counters[i].nc_name = NULL;
  346.         }
  347.     }
  348.  
  349.     (void) bzero((char *) nfs_counters,
  350.         MAXEXPORT * sizeof(NFSCounter));
  351.  
  352.     (void) bzero((char *) fil_counters,
  353.         MAXEXPORT * sizeof(FileCounter));
  354. }
  355.  
  356. /*
  357.  * parsetop - parse the top of the log session.
  358.  */
  359. void
  360. parsetop(fp)
  361. FILE *fp;
  362. {
  363.     int nskip = 0;
  364.     char line[BUFSIZ];
  365.  
  366.     /*
  367.      * Get lines...
  368.      */
  369.     while (fgets(line, sizeof(line), fp) != NULL) {
  370.         /*
  371.          * Second blank comment terminates this section.
  372.          */
  373.         if (!strcmp(line, "#\n")) {
  374.             if (++nskip == 2)
  375.                 return;
  376.  
  377.             continue;
  378.         }
  379.  
  380.         /*
  381.          * Grab the date - first one is start,
  382.          * otherwise end.
  383.          */
  384.         if (!strncmp(line, "Date: ", 6)) {
  385.             if (startdate == NULL) {
  386.                 startdate = savestr(line + 6);
  387.                 enddate = savestr(line + 6);
  388.             }
  389.             else {
  390.                 (void) strcpy(enddate, line + 6);
  391.             }
  392.  
  393.             continue;
  394.         }
  395.     }
  396. }
  397.  
  398. /*
  399.  * parsetotals - parse the totals section.
  400.  */
  401. void
  402. parsetotals(fp)
  403. FILE *fp;
  404. {
  405.     int x, y, z;
  406.     int nskip = 0;
  407.     register char *s;
  408.     char line[BUFSIZ];
  409.  
  410.     /*
  411.      * Get lines...
  412.      */
  413.     while (fgets(line, sizeof(line), fp) != NULL) {
  414.         /*
  415.          * Seond blank comment terminates this section.
  416.          */
  417.         if (!strcmp(line, "#\n")) {
  418.             if (++nskip == 2)
  419.                 return;
  420.  
  421.             continue;
  422.         }
  423.  
  424.         /*
  425.          * Grab the interval packets and add them.
  426.          */
  427.         if (!strncmp(line, "Interval Packets:", 17)) {
  428.             (void) sscanf(line + 17, "%d %d %d", &x, &y, &z);
  429.  
  430.             total_pkts += x;
  431.             tohost_pkts += y;
  432.             dropped_pkts += z;
  433.  
  434.             continue;
  435.         }
  436.     }
  437. }
  438.  
  439. /*
  440.  * parsepkts - parse packet counter section.
  441.  */
  442. void
  443. parsepkts(fp)
  444. FILE *fp;
  445. {
  446.     int x, y, z;
  447.     int nskip = 0;
  448.     register int i;
  449.     register char *s;
  450.     char line[BUFSIZ];
  451.  
  452.     /*
  453.      * Get lines...
  454.      */
  455.     while (fgets(line, sizeof(line), fp) != NULL) {
  456.         /*
  457.          * Second blank comment terminates this section.
  458.          */
  459.         if (!strcmp(line, "#\n")) {
  460.             if (++nskip == 2)
  461.                 return;
  462.  
  463.             continue;
  464.         }
  465.  
  466.         /*
  467.          * Find the numbers.
  468.          */
  469.         if ((s = index(line, ':')) == NULL)
  470.             continue;
  471.  
  472.         *s++ = NULL;
  473.  
  474.         /*
  475.          * Find the type we need.
  476.          */
  477.         for (i = 0; i < PKT_NCOUNTERS; i++) {
  478.             if (!strcmp(line, pkt_counters[i].pc_name)) {
  479.                 (void) sscanf(s, "%d %d%% %d", &x, &y, &z);
  480.  
  481.                 pkt_counters[i].pc_total += x;
  482.                 break;
  483.             }
  484.         }
  485.     }
  486. }
  487.  
  488. /*
  489.  * parsenfs - parse the NFS counter section.
  490.  */
  491. void
  492. parsenfs(fp)
  493. FILE *fp;
  494. {
  495.     int x, y, z;
  496.     int nskip = 0;
  497.     register int i;
  498.     register char *s;
  499.     char line[BUFSIZ];
  500.  
  501.     /*
  502.      * Get lines...
  503.      */
  504.     while (fgets(line, sizeof(line), fp) != NULL) {
  505.         /*
  506.          * Second blank comment terminates this section.
  507.          */
  508.         if (!strcmp(line, "#\n")) {
  509.             if (++nskip == 2)
  510.                 return;
  511.  
  512.             continue;
  513.         }
  514.  
  515.         /*
  516.          * Find the numbers.
  517.          */
  518.         if ((s = index(line, ':')) == NULL)
  519.             continue;
  520.  
  521.         *s++ = NULL;
  522.  
  523.         /*
  524.          * Find the NFS counter we want.
  525.          */
  526.         if ((i = findnfs(line)) < 0)
  527.             continue;
  528.  
  529.         (void) sscanf(s, "%d %d%% %d", &x, &y, &z);
  530.         nfs_counters[i].nc_total += x;
  531.  
  532.         if ((s = index(s, '(')) != NULL)
  533.             parseproc(s, nfs_counters[i].nc_proc);
  534.     }
  535. }
  536.  
  537. /*
  538.  * parsefile - parse the file counter section.
  539.  */
  540. void
  541. parsefile(fp)
  542. FILE *fp;
  543. {
  544.     int x, y, z;
  545.     int nskip = 0;
  546.     register int i;
  547.     register char *s;
  548.     char line[BUFSIZ];
  549.  
  550.     /*
  551.      * Get lines...
  552.      */
  553.     while (fgets(line, sizeof(line), fp) != NULL) {
  554.         /*
  555.          * Second blank comment terminates this section.
  556.          */
  557.         if (!strcmp(line, "#\n")) {
  558.             if (++nskip == 2)
  559.                 return;
  560.  
  561.             continue;
  562.         }
  563.  
  564.         /*
  565.          * Find the numbers.
  566.          */
  567.         if ((s = index(line, ':')) == NULL)
  568.             continue;
  569.  
  570.         *s++ = NULL;
  571.  
  572.         /*
  573.          * Find the file counter we want.
  574.          */
  575.         if ((i = findfile(line)) < 0)
  576.             continue;
  577.  
  578.         (void) sscanf(s, "%d %d%% %d", &x, &y, &z);
  579.         fil_counters[i].fc_total += x;
  580.  
  581.         if ((s = index(s, '(')) != NULL)
  582.             parseproc(s, fil_counters[i].fc_proc);
  583.     }
  584. }
  585.  
  586. /*
  587.  * parseproc - parse the NFS procedure counters.
  588.  */
  589. void
  590. parseproc(line, ctrs)
  591. Counter *ctrs;
  592. char *line;
  593. {
  594.     register int i;
  595.     register char *s;
  596.  
  597.     s = line + 1;
  598.  
  599.     for (i = 0; i < MAXNFSPROC; i++) {
  600.         ctrs[i] += atoi(s);
  601.  
  602.         if ((s = index(s, '/')) == NULL)
  603.             return;
  604.  
  605.         s++;
  606.     }
  607. }
  608.  
  609. /*
  610.  * dumpit - print out the information.
  611.  */
  612. void
  613. dumpit()
  614. {
  615.     float percent;
  616.     char buf[BUFSIZ];
  617.     register int i, nfstotal;
  618.  
  619.     (void) printf("NFSwatch logfile summary:\n");
  620.     (void) printf("    Log time:     %.24s to %.24s\n", startdate, enddate);
  621.     (void) printf("    Log entries:  %d\n", logentries);
  622.     (void) printf("    Packets from: %s", srchost);
  623.     (void) printf("    Packets to:   %s\n", dsthost);
  624.  
  625.     (void) printf("Total packets:\n");
  626.     (void) printf("    %8d (network) %8d (to host) %8d (dropped)\n\n",
  627.         total_pkts, tohost_pkts, dropped_pkts);
  628.  
  629.     (void) printf("Packet counters:\n");
  630.  
  631.     /*
  632.      * Print the packet counters.  Percentage is calculated as
  633.      * this counter over total packets.
  634.      */
  635.     for (i = 0; i < PKT_NCOUNTERS; i++) {
  636.         if (total_pkts) {
  637.             percent = ((float) pkt_counters[i].pc_total /
  638.                   (float) tohost_pkts) * 100.0;
  639.         }
  640.         else {
  641.             percent = 0.0;
  642.         }
  643.  
  644.         (void) sprintf(buf, "%s:", pkt_counters[i].pc_name);
  645.         (void) printf("    %-25s %8d %7.0f%%\n",
  646.             buf, pkt_counters[i].pc_total, percent);
  647.  
  648.         if (i == (PKT_NCOUNTERS/2 - 1))
  649.             (void) putchar('\n');
  650.     }
  651.  
  652.     /*
  653.      * Calculate the total number of NFS packets.
  654.      */
  655.     nfstotal = pkt_counters[PKT_NFSWRITE].pc_total +
  656.            pkt_counters[PKT_NFSREAD].pc_total;
  657.  
  658.     if (nfs_counters[0].nc_name != NULL)
  659.         (void) printf("\nNFS counters:\n");
  660.  
  661.     /*
  662.      * Print the NFS counters.  Percentage is calculated as
  663.      * packets this file system over total NFS packets.
  664.      */
  665.     for (i = 0; i < MAXEXPORT; i++) {
  666.         if (nfs_counters[i].nc_name == NULL)
  667.             continue;
  668.  
  669.         if (nfstotal) {
  670.             percent = ((float) nfs_counters[i].nc_total /
  671.                   (float) nfstotal) * 100.0;
  672.         }
  673.         else {
  674.             percent = 0.0;
  675.         }
  676.  
  677.         (void) sprintf(buf, "%s:", nfs_counters[i].nc_name);
  678.         (void) printf("    %-25s %8d %7.0f%%\n",
  679.             buf, nfs_counters[i].nc_total, percent);
  680.     }
  681.  
  682.     if (fil_counters[0].fc_name != NULL)
  683.         (void) printf("\nFile counters:\n");
  684.  
  685.     /*
  686.      * Print the file counters.  Percentage is calculated as
  687.      * packets this file over total NFS packets.
  688.      */
  689.     for (i = 0; i < MAXEXPORT; i++) {
  690.         if (fil_counters[i].fc_name == NULL)
  691.             continue;
  692.  
  693.         if (nfstotal) {
  694.             percent = ((float) fil_counters[i].fc_total /
  695.                   (float) nfstotal) * 100.0;
  696.         }
  697.         else {
  698.             percent = 0.0;
  699.         }
  700.  
  701.         (void) sprintf(buf, "%s:", fil_counters[i].fc_name);
  702.         (void) printf("    %-25s %8d %7.0f%%\n",
  703.             buf, fil_counters[i].fc_total, percent);
  704.     }
  705.  
  706.     (void) putchar('\014');
  707.  
  708.     /*
  709.      * If needed, put out the extra info.
  710.      */
  711.     if (verbose)
  712.         dumpit2();
  713. }
  714.  
  715. /*
  716.  * dumpit2 - dump even more information.
  717.  */
  718. void
  719. dumpit2()
  720. {
  721.     register int i, j, k;
  722.     
  723.     /*
  724.      * Print NFS procs in groups of 6.
  725.      */
  726.     for (i = 0; i < MAXNFSPROC; i += 6) {
  727.         /*
  728.          * Print header.
  729.          */
  730.         (void) printf("NFSwatch logfile summary:\n");
  731.         (void) printf("    Log time:     %.24s to %.24s\n",
  732.             startdate, enddate);
  733.         (void) printf("    Log entries:  %d\n", logentries);
  734.         (void) printf("    Packets from: %s", srchost);
  735.         (void) printf("    Packets to:   %s\n", dsthost);
  736.         (void) printf("NFS Procedure Call Summary (part %d):\n",
  737.             ((i / 6) + 1));
  738.         (void) printf("                         ");
  739.  
  740.         for (j = 0; j < 6; j++)
  741.             (void) printf("%s ", nfs_procs[i+j]);
  742.  
  743.         (void) putchar('\n');
  744.  
  745.         /*
  746.          * Print NFS counters.
  747.          */
  748.         for (j = 0; j < MAXEXPORT; j++) {
  749.             if (nfs_counters[j].nc_name == NULL)
  750.                 continue;
  751.  
  752.             (void) printf("%-25s", nfs_counters[j].nc_name);
  753.  
  754.             for (k = 0; k < 6; k++) {
  755.                 (void) printf("%8d ",
  756.                     nfs_counters[j].nc_proc[i+k]);
  757.             }
  758.  
  759.             (void) putchar('\n');
  760.         }
  761.  
  762.         if (fil_counters[0].fc_name != NULL)
  763.             (void) putchar('\n');
  764.  
  765.         /*
  766.          * Print file counters.
  767.          */
  768.         for (j = 0; j < MAXEXPORT; j++) {
  769.             if (fil_counters[j].fc_name == NULL)
  770.                 continue;
  771.  
  772.             (void) printf("%-25s", fil_counters[j].fc_name);
  773.  
  774.             for (k = 0; k < 6; k++) {
  775.                 (void) printf("%8d ",
  776.                     fil_counters[j].fc_proc[i+k]);
  777.             }
  778.  
  779.             (void) putchar('\n');
  780.         }
  781.  
  782.         (void) putchar('\014');
  783.     }
  784. }
  785.  
  786. /*
  787.  * findnfs - find the counter associated with name.
  788.  */
  789. int
  790. findnfs(name)
  791. char *name;
  792. {
  793.     register int i;
  794.  
  795.     /*
  796.      * Look for it.
  797.      */
  798.     for (i = 0; i < MAXEXPORT; i++) {
  799.         /*
  800.          * At end of list.
  801.          */
  802.         if (nfs_counters[i].nc_name == NULL)
  803.             break;
  804.  
  805.         /*
  806.          * Found it.
  807.          */
  808.         if (!strcmp(name, nfs_counters[i].nc_name))
  809.             return(i);
  810.     }
  811.  
  812.     /*
  813.      * If there's room, add it to the list.
  814.      */
  815.     if (i < MAXEXPORT) {
  816.         nfs_counters[i].nc_name = savestr(name);
  817.         return(i);
  818.     }
  819.  
  820.     return(-1);
  821. }
  822.  
  823. /*
  824.  * findfile - find the counter assopciated with name.
  825.  */
  826. int
  827. findfile(name)
  828. char *name;
  829. {
  830.     register int i;
  831.  
  832.     /*
  833.      * Look for it.
  834.      */
  835.     for (i = 0; i < MAXEXPORT; i++) {
  836.         /*
  837.          * At end of list.
  838.          */
  839.         if (fil_counters[i].fc_name == NULL)
  840.             break;
  841.  
  842.         /*
  843.          * Found it.
  844.          */
  845.         if (!strcmp(name, fil_counters[i].fc_name))
  846.             return(i);
  847.     }
  848.  
  849.     /*
  850.      * If there's room, add it to the list.
  851.      */
  852.     if (i < MAXEXPORT) {
  853.         fil_counters[i].fc_name = savestr(name);
  854.         return(i);
  855.     }
  856.  
  857.     return(-1);
  858. }
  859.  
  860. /*
  861.  * savestr - save string in dynamic memory.
  862.  */
  863. char *
  864. savestr(s)
  865. char *s;
  866. {
  867.     char *t;
  868.     char *malloc();
  869.  
  870.     if ((t = malloc(strlen(s) + 1)) == NULL) {
  871.         (void) fprintf(stderr, "%s: out of memory.\n", pname);
  872.         (void) exit(1);
  873.     }
  874.  
  875.     (void) strcpy(t, s);
  876.  
  877.     return(t);
  878. }
  879. @
  880.  
  881.  
  882. 3.4
  883. log
  884. @Corrected Jeff's address.
  885. @
  886. text
  887. @d2 1
  888. a2 1
  889. static char *RCSid = "$Header: /home/harbor/davy/system/nfswatch/RCS/nfslogsum.c,v 3.3 1993/01/15 19:33:39 davy Exp davy $";
  890. d18 3
  891. @
  892.  
  893.  
  894. 3.3
  895. log
  896. @Miscellaneous cleanups.
  897. @
  898. text
  899. @d2 1
  900. a2 1
  901. static char *RCSid = "$Header: /home/harbor/davy/system/nfswatch/RCS/nfslogsum.c,v 3.2 1993/01/14 03:41:21 davy Exp davy $";
  902. d13 1
  903. a13 1
  904.  * 1285 Electrical Engineering Building        100 Hamilton Avenue
  905. d18 3
  906. @
  907.  
  908.  
  909. 3.2
  910. log
  911. @Changed "Yellow Pages/NIS" to "YP/NIS/NIS+".
  912. @
  913. text
  914. @d2 1
  915. a2 1
  916. static char *RCSid = "$Header: /home/harbor/davy/system/nfswatch/RCS/nfslogsum.c,v 3.1 1993/01/13 20:18:17 davy Exp davy $";
  917. d5 2
  918. d11 5
  919. a15 5
  920.  * SRI International                Digital Equipment Corporation
  921.  * 333 Ravenswood Avenue            Western Research Laboratory
  922.  * Menlo Park, CA 94025                100 Hamilton Avenue
  923.  * davy@@erg.sri.com                Palo Alto, CA 94301
  924.  *                        mogul@@decwrl.dec.com
  925. d18 3
  926. a37 1
  927. #include "os.h"
  928. @
  929.  
  930.  
  931. 3.1
  932. log
  933. @Put in OS-specific define scheme, and merged in Tim Hudson's code for
  934. SGI systems (as yet untested).
  935. @
  936. text
  937. @d2 1
  938. a2 1
  939. static char *RCSid = "$Header: /home/harbor/davy/system/nfswatch/RCS/nfslogsum.c,v 3.0 1991/01/23 08:23:08 davy Exp davy $";
  940. d16 4
  941. d262 1
  942. a262 1
  943.     pkt_counters[PKT_YELLOWPAGES].pc_name = "Yellow Pages/NIS";
  944. @
  945.  
  946.  
  947. 3.0
  948. log
  949. @NFSWATCH Version 3.0.
  950. @
  951. text
  952. @d2 1
  953. a2 1
  954. static char *RCSid = "$Header: /tmp_mnt/net/sparky.a/davy/system/nfswatch/RCS/nfslogsum.c,v 1.2 90/08/17 15:47:27 davy Exp Locker: davy $";
  955. d15 4
  956. a18 1
  957.  * $Log:    nfslogsum.c,v $
  958. d29 1
  959. @
  960.  
  961.  
  962. 1.2
  963. log
  964. @NFSWATCH Version 2.0.
  965. @
  966. text
  967. @d2 1
  968. a2 1
  969. static char *RCSid = "$Header: /tmp_mnt/net/sparky.a/davy/system/nfswatch/RCS/nfslogsum.c,v 1.1 88/11/29 11:20:38 davy Released Locker: davy $";
  970. d8 6
  971. a13 5
  972.  * David A. Curry
  973.  * SRI International
  974.  * 333 Ravenswood Avenue
  975.  * Menlo Park, CA 94025
  976.  * davy@@itstd.sri.com
  977. d16 3
  978. d254 1
  979. a254 1
  980.     pkt_counters[PKT_YELLOWPAGES].pc_name = "Yellow Pages";
  981. @
  982.  
  983.  
  984. 1.1
  985. log
  986. @NFSWATCH Release 1.0
  987. @
  988. text
  989. @d2 1
  990. a2 1
  991. static char *RCSid = "$Header$";
  992. d9 4
  993. a12 5
  994.  * Research Institute for Advanced Computer Science
  995.  * Mail Stop 230-5
  996.  * NASA Ames Research Center
  997.  * Moffett Field, CA 94035
  998.  * davy@@riacs.edu
  999. d14 4
  1000. a17 1
  1001.  * $Log$
  1002. @
  1003.